﻿using System;
using JetBrains.Annotations;
using MugenMvvmToolkit.Interfaces;

namespace MugenMvvmToolkit.Utils
{
    /// <summary>
    ///     A static helper class that includes various parameter checking routines.
    /// </summary>
    [Obsolete("Use the MugenMvvmToolkit.Should class instead.")]
    public static class Validate
    {
        /// <summary>
        ///     Throws <see cref="ArgumentNullException" /> if the given argument is null.
        /// </summary>
        /// <exception cref="ArgumentNullException"> if tested value if null.</exception>
        /// <param name="argumentValue">Argument value to test.</param>
        /// <param name="paramName">Name of the parameter being tested. </param>
        public static void ArgumentNotNull(object argumentValue, [InvokerParameterName] string paramName)
        {
            Should.NotBeNull(argumentValue, paramName);
        }

        /// <summary>
        ///     Throws <see cref="ArgumentNullException" /> if the given argument is null or empty.
        /// </summary>
        /// <exception cref="ArgumentNullException"> if tested value if null.</exception>
        /// <param name="argumentValue">Argument value to test.</param>
        /// <param name="paramName">Name of the parameter being tested. </param>
        public static void ArgumentNotNullOrEmpty(string argumentValue, [InvokerParameterName] string paramName)
        {
            Should.NotBeNullOrEmpty(argumentValue, paramName);
        }

        /// <summary>
        ///     Throws <see cref="ArgumentNullException" /> if the given argument is null.
        /// </summary>
        /// <exception cref="ArgumentNullException"> if tested value if null.</exception>
        /// <param name="argumentValue">Argument value to test.</param>
        /// <param name="paramName">Name of the parameter being tested. </param>
        public static void PropertyNotNull(object argumentValue, string paramName)
        {
            Should.PropertyBeNotNull(argumentValue, paramName);
        }

        /// <summary>
        ///     Determines whether an instance of the <see cref="T:System.Type" /> can be assigned from an instance of the
        ///     specified Type.
        /// </summary>
        public static void IsAssignable(Type typeFrom, Type typeTo, string message = "")
        {
            Should.BeOfType(typeFrom, message, typeTo);
        }

        /// <summary>
        ///     Throws an exception that indicates that specified method is not supported.
        /// </summary>
        /// <param name="methodName">The specified method signature.</param>
        public static void ThrowMethodNotSupported(string methodName)
        {
            Should.MethodBeSupported(false, methodName);
        }

        /// <summary>
        ///     Makes sure that the object is not disposed.
        /// </summary>
        public static void EnsureIsNotDisposed(IIocAdapter iocAdapter)
        {
            iocAdapter.NotBeDisposed();
        }
    }
}